<?php

	$query        = "SELECT * from friends where user1='$profile_id'";
	$result = mysql_query($query);
	if (mysql_num_rows($result)){ 
		while($friend = mysql_fetch_array($result)) {
			$friend_id = $friend['user2'];
			$query2        = "SELECT * from friends where user2='$profile_id' and user1='$friend_id'";
			$result2 = mysql_query($query2);
			if (mysql_num_rows($result2)){
				$query3 = "SELECT * from `users` where `id`='$friend_id'";
				$result3 = mysql_query($query3);
				$profileinfo = mysql_fetch_array($result3);
				$img = "/index.php?do=getphoto&id=".$profileinfo['photo']."&size=75&square=1";			
				$friend_name  = $profileinfo['name'];
				$friends = "<div class=\"userthumb\">
											<a href=\"/index.php?do=profile&profile_id=$friend_id\">												
											$friend_name</a><br><!--$status--><br><img src=\"$img\" title=\"$TXT_NOIMG\" 
												width=\"75\" height=\"75\"></div>$friends";
			
			}
		}
	} else {
		// no friends :( 
		$friends = GetLangString($lang,"txt_nofriends");
	}

	$SITE_MIDDLE .= FormatElement ( GetLangString ( $lang, "txt_friends" ) , $friends ) ;

?>
